package Chapter05.Fruite;

import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Market market = new Market();
        Scanner scanner = new Scanner(System.in);

        // Farmer registration
        market.registerFarmer("farmer1", "123456");

        // User registration
        market.registerUser("user1", "123456");

        // Farmer login
        Farmer farmer = market.loginFarmer("farmer1", "123456");

        // Add fruits
        market.addFruit(farmer, "apple", 1.5);
        market.addFruit(farmer, "banana", 0.8);
        market.addFruit(farmer, "orange", 1.2);

        // User login
        User user = market.loginUser("user1", "123456");

        // Search fruits
        List<Fruit> fruits = market.searchFruit("apple");
        for (Fruit fruit : fruits) {
            System.out.println(fruit.getName() + " - " + fruit.getPrice());
        }

        // Add to cart
        user.addToCart(fruits.get(0));
        user.addToCart(fruits.get(1));

        // Checkout
        market.checkout(user);
    }
}
